#include<stdio.h>
#include<stdlib.h>
int v[100];
int e[20][20];
int a;
int b;
void Init() {
	a = 5;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < a; j++) {
			e[i][j] = 1234567;
		}
	}
	b = 8;
	e[0][1] = 1;
	e[0][3] = 5;
	e[0][2] = 7;
	e[0][4] = 2;
	e[1][2] = 15;
	e[2][3] = 77;
	e[3][4] = 24;
	e[4][1] = 67;
}
void Prim() {
	int mark[5] = {};
	int n[8] = {};
	n[0] = 0;
	mark[0] = 0;
	for (int i = 1; i < a; i++) {
		n[i] = e[0][i];
	}
	for (int i = 0; i < a; i++) {
		int min = 1234567;
		int b;
		for (int j = 0; j < b; j++) {
			if (min > n[j] && n[j] != 0) {
				min = n[j];
				b = j;
			}
		}
		mark[i] = b;
		n[b] = 0;
		printf("%d %d\n", n[b], b);
		for (int m; m < b; m++) {
			if (e[b][m] < n[m] && n[m] != 0) {
				n[m] = e[b][m];
			}
		}
	}
}
int main() {
	Init();
	Prim();
}
